package com.js.common.response;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author ygl
 * @create 2018-11-01
 * @DESCRIPTION
 * 分页查询返回结果
 **/
public class TableResultResponse<T> extends BaseResponse {

    @Setter
    @Getter
    TableData<T> data;

    public TableResultResponse(long total, List<T> rows) {
        this.data = new TableData<T>(total, rows);
    }

    public TableResultResponse() {
        this.data = new TableData<T>();
    }

    TableResultResponse<T> total(int total) {
        this.data.setTotal(total);
        return this;
    }

    TableResultResponse<T> total(List<T> rows) {
        this.data.setRows(rows);
        return this;
    }

    public class TableData<T> {

        @Setter
        @Getter
        long total;
        @Setter
        @Getter
        List<T> rows;

        public TableData(long total, List<T> rows) {
            this.total = total;
            this.rows = rows;
        }

        public TableData() {
        }
    }

}
